package com.tester.zc.test001.fourth;

/**
 * 手机工厂类
 *
 * @Author zhoucan
 * @Date 2022/12/4
 */
public class PhoneFactory {

    public Phone productionPhone(String type){
        //根据不同类型创建不同的子类对象
        Phone phone;
        if("iphone".equals(type)){
            phone = new ApplePhone();
        }else if("vivo".equals(type)){
            phone = new VivoPhone();
        }else{
            throw new RuntimeException("没有该型号手机！");
        }
        return phone;
    }
}
